package com.hks360.car_treasure.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hks360.car_treasure.R;
import com.hks360.car_treasure.adapter.FragmentAdapter;
import com.hks360.car_treasure.common.FragmentKey;
import com.hks360.car_treasure.factory.FragmentFactory;
import com.hks360.library.util.UIUtil;
import com.hks360.nohttp.Response;

import net.hks360.viewpagerindicator.CirclePageIndicator;

import java.util.ArrayList;
import java.util.List;

/**
 * 信息Fragment
 */
public class InfoFragment extends BaseFragment {
    private List<Fragment> fragments;
    private FragmentAdapter mAdapter;
    private ViewPager mPager;
    private CirclePageIndicator mIndicator;
    private int count = 2;

    @Override
    public void setupView() {
        mPager = UIUtil.findViewById(mRootView, R.id.pagerinfo);
        mIndicator = UIUtil.findViewById(mRootView,R.id.indicatorcircle);
    }

    private void initFragment() {
        fragments = new ArrayList<Fragment>();
        Fragment fragment = FragmentFactory.createFragment(FragmentKey.USER);
        fragments.add(fragment);
        fragment = FragmentFactory.createFragment(FragmentKey.DEVICE_NAME);
        fragments.add(fragment);
    }

    @Override
    public void initData() {
        initFragment();
        mAdapter = new FragmentAdapter(getChildFragmentManager(),fragments);
        mPager.setAdapter(mAdapter);
        mIndicator.setViewPager(mPager);
    }

    @Override
    public void addListener() {

    }

    @Override
    public void initView() {
        initTitleBar(R.string.title_info);
        setupView();
        initData();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mRootView = inflater.inflate(R.layout.fragment_userinfo,null);
        initView();
        return mRootView;
    }

    @Override
    public void viewClick(View v) {

    }

}
